package com.example.test.主方法运行测试;

import cn.hutool.core.collection.CollectionUtil;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

public class 集合元素统计 {

    public static void main(String[] args) {

        List<Integer> list = CollectionUtil.newArrayList(1, 2, 3, 4, 7, 4, 3, 2, 4, 7, 8, 9);

        Map<Integer, Long> collect = list.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));

        collect.forEach((integer, aLong) -> {
            if (aLong > 1) {
                System.out.println(integer);
            }
        });

    }

}




